package com.lagou.controller;

import com.lagou.entity.OrderDetail;
import com.lagou.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/status")
public class IndexController {

    @Autowired
    private OrderRepository orderRepository;

    @GetMapping("/success")
    public String success() {
        return "success";
    }

    @GetMapping("fail")
    public String fail(ModelMap modelMap) {
        final List<OrderDetail> allByOrderStatus = orderRepository.findAllByOrderStatus(3);
        modelMap.put("list", allByOrderStatus);
        return "fail";
    }
}
